# Copyright (c) 2014 by Michael Zahniser
#
# Endless Sky is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later version.
#
# Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.

mission "First Contact: Unfettered"
	landing
	source
		attributes "unfettered"
	on offer
		conversation
			branch hai
				has "First Contact: Hai: offered"
			branch news
				has "hr: heard the news"
			`This planet is populated by a hostile alien species that resembles giant, intelligent squirrels. Although despite their hostility while in orbit, they pay little mind to you on the surface. Do you want to approach one of them?`
			choice
				`	(Sure.)`
					goto sure
				`	(Not now, it's too risky.)`
					defer
			
			label news
			`This planet is populated by a hostile alien species that resembles giant, intelligent squirrels. Their ships look exactly like the ones that you saw on the news. Although despite their hostility while in orbit, they pay little mind to you on the surface.`
			
			label sure
			`	You catch the eye of one of the alien dock workers and it walks over. "Ah," it says, "the monkey is curious. The monkey has never been face to face with a true Hai before?"`
			choice
				`	"Hai? Is that what you call yourselves?"`
					goto name
				`	"What do you mean, 'true Hai'?"`
					goto true
				`	"Why did you shoot at me? Are you at war?"`
					goto war

			label hai
			`The Hai here appear to be at war with the rest of their species. Do you want to approach one of them and ask why?`
			choice
				`	(Sure.)`
				`	(Not now, it's too risky.)`
					defer
			`	You catch the eye of one of the Hai dock workers and they walk over. "Ah," they say, "the monkey is curious. The monkey has never been face to face with a true Hai before?"`
			choice
				`	"No, I've encountered many of your brethren south of here."`
					goto brethren
				`	"What do you mean, 'true Hai'?"`
					goto true
				`	"Why are you at war with everyone else?"`
					goto everyone
			
			label brethren
			`	They hiss. "They are not true Hai. We are Hai. The unaltered. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label true
			`	"It means that we are unaltered, Hai as Hai were first born to be. Hai the conquerors. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label name
			`	"We are Hai. Hai the conquerors. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label war
			`	"We fight to defend ourselves from extinction," they say.`
			`	"Extinction?" you ask. "Do you mean that there are no other Hai?"`
			`	"We are all that is left of the original Hai," they say. "Unaltered. The conquerors. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label everyone
			`	"We fight to defend ourselves from extinction," they say.`
			`	"Extinction?" you ask. "Do you mean that you are not the same species as the other Hai?"`
			`	"Indeed," they say. "We are all that is left of the original Hai. Unaltered. The conquerors. We were masters of a hundred worlds before human monkeys had learned the use of thumbs."`
				goto masters
			
			label masters
			choice
				`	"Where was your territory? Why have I never heard of you before?"`
				`	"What do you mean, the Hai were altered?"`
			
			`	"This is our story," they say. "Once, many worlds beyond wormhole were ours. Once, hundred thousand years now gone. We needed more worlds. A species that does not expand becomes like brackish water, like stunted tree. But dragonfolk in the south had created hyperdrive, and human monkeys had begun banging rocks together in what the Drak said was very intelligent fashion. So we were forbidden from taking more worlds."`
			branch sheragi
				has "Rim Archaeology 6: offered"
			`	"'Dragonfolk?'" you ask. "I've never heard of them."`
			`	"Sheragi," they say, "they are extinct. Only their dumb ancestors survive, just as monkeys will outlast the thinking humans."`
				goto altered

			label sheragi
			`	"'Dragonfolk?'" you ask. "Do you mean the Sheragi?"`
			`	"Impressive," they reply, "the monkey knows of Sheragi. We outlived them all. Funny that only their dumb ancestors survive, just as monkeys will outlast the thinking humans."`

			label altered
			`	"How were you altered?" you ask.`
			`	They say, "We Hai fought Sheragi and took worlds that Drak said belonged to them, worlds that Sheragi had not yet even discovered. Drak retaliated. On all Hai worlds, Drak ships appeared in orbit. Sickness swept each planet: quick fever, strange feeling of frailness, like you are brittle bones with mouth full of dirt. Victims left alive, but all ambition gone, no desire but to die of comfortable old age."`
			choice
				`	"Did you try to resist the Drak?"`
					goto resist
				`	"How do you know this, if it happened a hundred thousand years ago?"`
					goto know
			
			label resist
			`	"Silly monkey," they say, "none can resist. They are strong. Their will prevails. And their will is for the galaxy to be a zoo, little remnants of each species all in separate cages. For now they let humans run free so humans will grow in knowledge, but soon they will fashion a cage for humans too."`
				goto help
			
			label know
			`	"All Hai know. The story is passed down. Others tell an altered version, where the way of peace was choice and not an inflicted wound, but some in each generation learn truth, and join us here."`
				goto help
			
			label help
			choice
				`	"That is a frightening story. Thank you for taking the time to speak with me."`
					decline
				`	"Is there anything I can do to help you?"`
			action
				set "unfettered requested jump drives"
			`	"If you are ever willing to sell us a jump drive," they say, "we will richly reward you. And if you discover the secret of how we can construct our own jump drives and escape from this prison, bring it to us and you will live as a god among us."`
			choice
				`	"I'm sorry, I don't know the secret of the jump drive. No human being does."`
				`	"If I ever have an extra jump drive to sell, I will bring it to you."`
					goto sell
			`	"Then leave us alone," they say, and they walk off.`
				decline
			
			label sell
			`	"Bring us a jump drive," they say, "and we will count you among our friends. Bring us more, and we may even consider you worthy of a share of the plunder, when we take back what is ours."`
				decline
	
	on decline
		log "Factions" "Unfettered Hai" `The "Unfettered" are a faction within the Hai species who are not as peaceful as the rest, and are normally not friendly toward humans. They claim that long ago the Drak altered the Hai to make them docile and peaceful, and that the Unfettered are descendants of those Hai who avoided undergoing that alteration. They are seeking jump drives so that they can escape the "prison" they are now stuck in: a few deteriorating worlds on the far northern edge of Hai space.`
		log "Factions" "Sheragi" `The Unfettered Hai say that a dragon-like species called the "Sheragi" who are long extinct used to live in human space, back when much of what is now human territory was occupied by the Hai.`



mission "Unfettered Jump Drive 1"
	minor
	landing
	name "More Jump Drives"
	description "The Unfettered Hai have promised you rich rewards if you bring them more jump drives."
	to offer
		has "First Contact: Unfettered: offered"
		not "Wanderers: Jump Drive Source: active"
	to fail
		has "event: wanderers: unfettered invasion starts"
	to complete
		has "Unfettered Jump Drive 2: offered"
	source
		attributes "unfettered"
	on offer
		conversation
			`The Unfettered have clearly noticed that you have a jump drive; a large crowd of them has gathered around your ship. Do you want to talk with them, and perhaps arrange a sale of your jump drive?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	As soon as you approach the crowd, one of them steps forward and says, "One million credits, and the friendship of the true Hai people. This is our offer, for the jump drive."`
			choice
				`	"Sure, I will accept that deal."`
					goto end
				`	"Can you offer me more than that?"`
					goto more
				`	"How will my ship leave here without my jump drive?"`
			
			`	"We can give you a hyperdrive in its place, if required," they say, "and you will be counted as our friend, so you will not need to leave here quickly, or under threat of violence." You can't help but wonder if they will try to take your ship by force if you do not agree to the deal.`
			`	"Oh, and by the way, you will no longer be required to keep your Anomalocaris in working condition to guarantee our friendship," they add.`
				to display
					has "Hai Legacy 3: done"
			choice
				`	"Okay, I accept your generous offer."`
					goto end
				`	"Sorry, but if I give you this jump drive, I will lose my ability to capture more of them. Be patient, and I will bring you several of them when I am able."`
					goto refuse
			
			label refuse
			`	They ponder this for a while, and says, "Very well. Our offer stands, whenever you choose to return." They allow you to return to your ship peacefully.`
				defer
			
			label more
			`	"Do not underestimate the value of our friendship," they say. "Soon we will become powerful once more, with many fruitful worlds under our control, and when that day comes you will benefit greatly from being our ally."`
			choice
				`	"Okay, as long as you give me a hyperdrive to take its place, I'll give you my jump drive."`
					to display
						"outfit (cargo): Jump Drive" + "outfit (flagship installed): Hyperdrive" + "outfit (flagship installed): Scram Drive" + "outfit (flagship installed): Jump Drive" == 1
					goto end
				`	"You can take the jump drive, but I don't need a hyperdrive in exchange."`
					to display
						"outfit (cargo): Jump Drive" + "outfit (flagship installed): Hyperdrive" + "outfit (flagship installed): Scram Drive" + "outfit (flagship installed): Jump Drive" > 1
					goto spareJD
				`	"Sorry, but if I give you this jump drive, I will lose my ability to capture more of them. Be patient, and I will bring you several of them when I am able."`
					goto refuse
			
			label end
			branch spareJD
				"outfit (cargo): Jump Drive" + "outfit (flagship installed): Hyperdrive" + "outfit (flagship installed): Scram Drive" + "outfit (flagship installed): Jump Drive" > 1
			action
				outfit "Hyperdrive" 1
			`	The Unfettered engineers quickly and carefully remove your jump drive and replace it with an ordinary hyperdrive. You sincerely hope that you are not making a mistake by giving them this new technology. "Remember," one of them says as they hand you your payment, "when you acquire more jump drives, return here with them and we will give you further rewards. Until then, may fortune favor you, human friend."`
				accept
			label spareJD
			`	The Unfettered engineers quickly retrieve the jump drive. You sincerely hope that you are not making a mistake by giving them this new technology. "Remember," one of them says as they hand you your payment, "when you acquire more jump drives, return here with them and we will give you further rewards. Until then, may fortune favor you, human friend."`
				accept
	
	on accept
		outfit "Jump Drive" -1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 10



mission "Unfettered Jump Drive 2"
	minor
	landing
	name "More Jump Drives"
	description "The Unfettered Hai have promised you rich rewards, and more information about their plans, if you bring them more jump drives."
	to offer
		has "Unfettered Jump Drive 1: offered"
		not "Wanderers: Jump Drive Source: active"
	to fail
		has "event: wanderers: unfettered invasion starts"
	to complete
		has "Unfettered Jump Drive 3: offered"
	source
		attributes "unfettered"
	on offer
		conversation
			`As before, when you land on this Unfettered world with a jump drive, a large crowd gathers around your ship. Clearly they are hoping that once again you will arrange a sale. Do you want to bargain with them?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	When you approach the crowd, one of them says, "Greetings, human friend. We have made you known to all our brothers and sisters as one of the few creatures who have chosen to help the true Hai to gain their freedom. If you give us another jump drive, we will pay you another million credits, and make you one of our emissaries to collect the payments with which our frail brothers seek to buy peace. Will you accept this exchange?"`
			choice
				`	"Sorry, I need this jump drive right now, but I will come back later and sell it to you."`
					defer
				`	"Yes, I will sell you my jump drive."`
			
			branch spareJD
				"outfit (cargo): Jump Drive" + "outfit (flagship installed): Hyperdrive" + "outfit (flagship installed): Scram Drive" + "outfit (flagship installed): Jump Drive" > 1
			action
				outfit "Hyperdrive" 1
			label spareJD
			`	Once again, they swap your jump drive for a hyperdrive, and pay you far more than you could sell a jump drive for anywhere else. "We will tell the other true Hai to offer you jobs in our job boards," they tell you, "and remember that we need still more jump drives."`
			choice
				`	"Then I will find more, and bring them to you."`
					accept
				`	"Can you tell me what you are using them for?"`
			`	"Not yet. If you further prove your friendship, perhaps we will." You assure them that you will continue to do your best to assist them.`
				accept
	
	on accept
		outfit "Jump Drive" -1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 20
		fail "Unfettered Jump Drive 1"



mission "Unfettered Jump Drive 3"
	minor
	landing
	invisible
	to offer
		has "Unfettered Jump Drive 2: offered"
		not "Wanderers: Jump Drive Source: active"
	source
		attributes "unfettered"
	on offer
		conversation
			`You have another jump drive, and the Unfettered will certainly be willing to pay you well for it. They also hinted that they might be willing to give you more information about what they plan to use the jump drives for. Do you want to sell them another drive?`
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	You meet up with some local Unfettered leaders, and they again pay you a million credits and arrange for your jump drive to be swapped out of your ship. "If you bring more, we will continue to pay you," they say.`
			choice
				`	"Can you tell me what you are using the jump drives for?"`
				`	"Thank you, I will certainly bring more of them when I am able."`
					goto job
			action
				set "unfettered know of wanderers"
			`	After a brief and hushed discussion in their own language, one of the leaders says, "You have proven your worth, so we will share our secret. The Hai once owned many worlds on the galactic fringe, a territory we can only visit using the jump drive. Those worlds are fruitful and nearly uninhabited. We will reclaim them as our own, and there will be food there to feed the Unfettered for many thousands of years to come."`
			branch know
				or
					has "First Contact: Wanderer: offered"
					has "First Contact: Wanderer (Before Hai): offered"
			choice
				`	"Is there any other way I can help you to reclaim those worlds?"`
					goto help
				`	"'Nearly uninhabited?' You mean another species inhabits some of those worlds now?"`
					goto wanderers
			
			label know
			`	You suspect that they are talking about the territory that is now inhabited by the Wanderers.`
			choice
				`	"Are you at war with the Wanderers? Can I help you to reclaim your territory?"`
					goto help
				`	"What are you going to do to the species that owns those worlds right now?"`
					goto wanderers
			
			label help
			`	"Your help may indeed be beneficial to us," says the leader. "I will tell the others to contact you if they have any particular missions you can undertake."`
			choice
				`	"I look forward to hearing from them."`
					goto job
				`	"What do you plan to do to the species that inhabits those worlds now?"`
			
			label wanderers
			`	"Those worlds are now held by a species of scavengers, who feast on the ruin of proud civilizations. Our scouts tell us that these carrion-feeders have wiped away nearly every Hai artifact, melting down our cities to make metal for their ships and factories, and hiding the scars of our wars beneath newly planted forests. They are an old and strong species, but few in number, and those worlds are ours by right."`
			`	You try to press them for more information, but they tell you nothing useful, aside from promising you that they will seek out your help when it is time to reclaim their territory.`
			label job
			branch spareJD
				"outfit (cargo): Jump Drive" + "outfit (flagship installed): Hyperdrive" + "outfit (flagship installed): Scram Drive" + "outfit (flagship installed): Jump Drive" > 1
			action
				outfit "Hyperdrive" 1
			label spareJD
			`	"If you want to provide us with more jump drives, visit the job board from now on," says the leader. "We will have warriors ready to receive them from you for the usual pay."`
				accept
	
	on accept
		outfit "Jump Drive" -1
		payment 1000000
		"reputation: Hai (Unfettered)" >?= 30
		fail "Unfettered Jump Drive 2"
		fail



mission "Unfettered Jump Drive Trading"
	minor
	landing
	invisible
	source "Darkcloak"
	substitutions
		<hood> ""
		<hood> ", with their face hidden,"
			has "unfettered: blade rodeo"
		<learned> ""
		<learned> "It did take you two tries, but I am glad that you were able to learn from your mistake. "
			"unfettered: blade rodeo" == 1
		<learned> "You finally learned from your mistakes. This is why our challenges are never fatal. "
			"unfettered: blade rodeo" == 2
		"<The engineer>" "The engineer, who had stepped back during the fight,"
		"<The engineer>" "The real engineer then moves out of the crowd,"
			"unfettered: blade rodeo" == 1
		"<The engineer>" "The engineer, who had stepped back during the fight, reveals their face and"
			"unfettered: blade rodeo" == 2
		"<as before (run)>" "You"
		"<as before (run)>" "As before, you"
			has "unfettered: dodged the blade"
		"<as before (flee)>" "You"
		"<as before (flee)>" "Just like last time, you"
			has "unfettered: flee from the blade"
		<leave> "She then leaves, to your surprise."
		<leave> "She then leaves, her anger barely contained."
			has "unfettered: blade rodeo"
	to offer
		has "Unfettered Jump Drive 3: offered"
		not "Wanderers: Jump Drive Source: active"
		not "Wanderers: Jump Drive Source: done"
		# There is no minimum amount of JD to sell (other than the first 3), except if you failed to prove yourself the first time.
		# "Unfettered Jump Drive 4: failed" represents the amount of JD sold.
		"unfettered: jd to sell" <= "Unfettered Jump Drive 4: failed"
		random < 20 + 8 * "Unfettered Jump Drive 4: failed"
	on offer
		conversation
			`As you exit your ship to head to the spaceport you see that an Unfettered Hai<hood> is waiting for you at your hatch.`
			`	As you get closer you surmise it is an engineer, judging by the writing pad and equipment they have. Maybe they mean to trade something other than money with you. Do you want to bargain for another drive with them?`
				to display
					not "unfettered: blade rodeo"
			`	They probably mean to offer the same deal of exchanging jump drives for weapons as before. Do you want to try and see if you can prove yourself worthy this time, and bargain for a jump drive?`
				to display
					has "unfettered: blade rodeo"
			choice
				`	(No.)`
					defer
				`	(Yes.)`
			`	As soon as you set foot on the world the supposed engineer drops her equipment and throws a blade at you just like before - it seems that she does not want to waste time with you anymore.`
				to display
					"unfettered: blade rodeo" == 1
				goto blade
			`	You exit your ship, but before you can even reach the engineer, another Unfettered shouts to attract your attention and then throws a blade at you, without any other warning or ceremony.`
				to display
					"unfettered: blade rodeo" > 1
				goto blade
			`	You exit your ship and immediately the engineer leads you to the outfitter. "We have weapons to show you for your assistance in providing us with jump drives. For now you will only be allowed to trade for the one, but if you continue to provide assistance to us, you may prove yourself worthy to access the others." They never stop to ask if you are actually interested in new weapons.`
			label repeat
			choice
				`	(Follow them.)`
					goto next
				`	"I'm not really interested in Hai weapons."`
					to display
						not "unfettered: uninterested in weapons"
					goto uninterested
				`	"I don't really want to do this right now."`
			action
				clear "unfettered: uninterested in weapons"
				"unfettered: jd to sell" ++
			`	"How rude. You better hope there will be someone else to guide you next time!" says the engineer as you return to your ship.`
				defer
			label uninterested
			action
				set "unfettered: uninterested in weapons"
			`	"These are not standard Hai weapons, Captain, trust me. Also, it would be ill-advised to judge before seeing them, would it not?"`
				goto repeat
			label next
			`	They lead you through the usual outfitter but then go to an area you have never noticed before, probably because you were not meant to. As you are about to pass through what you assume to be a security check, an Unfettered throws a blade at your face!`
			label blade
			`	You recognize the same Unfettered from last time; she must fancy throwing blades at people.`
				to display
					has "unfettered: blade rodeo"
			choice
				`	(Try to grab it.)`
					goto grab
				`	(Try to dodge it.)`
					goto dodge
				`	(Leap to the side and use my own weapon.)`
				`	(Flee.)`
					goto flee
			`	You leap to the side, grabbing your own weapon just in time to threaten the Unfettered that threw the blade at you. Seeming a bit surprised by your unconventional tactics, they lower their own weapon. "Well done! In truth, there is no higher honor than surviving on the field of battle, because only then can you bring loot back to those who need it! A tactic is only good if you can find and execute it quickly enough to give you an edge, which you did. <learned>I am Desneeparu, and it is my pleasure to meet you, Captain."`
				goto meet
			label grab
			`	You manage to grab the weapon, just in time to deflect an incoming attack from the same Unfettered. They duel with you for what feels like an eternity. At first you are astonished by the fact you have managed to survive this long, but you soon realize that, as you have not managed to land a single successful blow, this must be some kind of deliberate test.`
			`	Then, suddenly, you can feel the pace of your opponent change; the game is over. They strike a masterful blow that disarms you with ease before smiling and lowering their weapon. "It looks like you know what to do with a blade! <learned>I am Desneeparu, and it is a pleasure to meet you, Captain <last>!" she exclaims, before laughing at your surprised face. You realize she must have been toying with you from the beginning, but, nevertheless, she seems satisfied by your performance.`
			label meet
			action
				log "Minor People" "Desneeparu" `An Unfettered warrior that knows how to handle a blade. Was tested by her before being given access to new Unfettered weapons. Would have been a goner had she not been holding back.`
			`	She does some kind of salute with her fist before leaving. "I must go now. I hope you will find the weapon you need."`
			`	<The engineer> proceeds to take you underground to rows and rows of prototype weapons, some of which are being worked on by engineers. They explain, "We prefer to do most of our testing on the field of battle. We only make the most basic safety tests here before Unfettered captains can get their hands on them. They often start by going to Firelode to put the weapon to its limit, to ensure it will not explode in the middle of action. The more interest in a prototype, the more we develop it." You keep walking until you enter the outfitter section of the facility, where you notice the items on display are much more advanced than anything you have seen available on the surface: so much so it could almost pass for a 'normal' Hai outfitter, were it not for the overcharged, oppressive feel of the testing grounds.`
			`	"Welcome to the advanced section of the outfitter, Captain! It is only for our most distinguished guests. Now that you have sold us multiple jump drives, I can tell you that we offer something much more valuable than money. For now, I can only offer you the mighty Tripulse Shredder, but eventually we will give you access to all kinds of weapons. Two Tripulse Shredders and our sympathy for one jump drive is the deal I propose," they say, presenting the weapons to you. Now that you can take a closer look, you notice these weapons seem fairly similar to other Hai weaponry, but they are enhanced in one way or another. Alongside the Tripulses you can spot what look like a very small Ion Cannon and an Ion Cannon mounted turret.`
			label weapons
			choice
				`	"Tell me more about those Tripulse Shredders I can buy."`
					to display
						not "choice: tripulse"
					goto tripulse
				`	"I'll settle for the tripulse, then."`
					to display
						has "choice: tripulse"
					goto "buy tripulse"
				`	"Can you tell me more about that small ionic weapon?"`
					to display
						not "choice: blaster"
				`	"I'd like to learn about this... ion cannon mounted on a turret?"`
					to display
						not "choice: turret"
					goto turret
				`	"I would just prefer the money, actually."`
					goto money
			action
				set "choice: blaster"
			scene "outfit/hai ionic blaster"
			`	"Ah, the Blaster. It is favored by many Shield Beetle captains, because it can easily help them turn the tide of battle without needing to dedicate too much weapon space to it. Especially considering its other effects, its damage potential is serviceable. While it is true that it does not do enough ion damage to properly disable a ship on its own, it is able to jam their weapons and will give you the upper hand in a long fight. This is a more recent innovation, however, and some say it lacks the... finesse of others.`
				goto "back to choose"
			label turret
			action
				set "choice: turret"
			scene "outfit/hai ionic turret"
			`	"That is my preferred weapon out of all of them, by far. Unlike the Ion Cannon that is a hybrid weapon meant to damage the enemy from long range whilst applying a good deal of ionization, this one's role is mostly to disable enemy ships. Even a ship with many batteries will cower before this weapon! And due to its high range and fast turn-rate, small ships and even fighters will never bother you again!`
			label "back to choose"
			`	"However, we only have these weapons in very limited quantities, and as such we cannot afford to give these to you yet. So, about my offer, have you made up your mind?"`
				goto weapons

			label money
			`	"Oh. Well, in that case, we will not bother you again with this weapon, or any other, Captain, here or in the job board."`
			choice
				`	"Sounds good to me."`
				`	"Wait, what was that weapon again?"`
					goto tripulse
			action
				payment 1000000
				set "unfettered: money for drives"
			`	"As you wish. Do remember that if you want to sell further jump drives to us for money you may go to the job board."`
				goto end

			label tripulse
			action
				set "choice: tripulse"
			scene "outfit/tripulse shredder"
			`	"The Tripulse Shredder may seem crude, but it packs a punch! Its specialty is how it combines a lot of firepower in one gun slot, and, due to its burst nature, it's perfect for pilots who already use hit and run tactics. Some captains even say that a Sea Scorpion can get the upper hand against a Shield Beetle when it uses four of them, if you know what you're doing, of course! As I said, I may offer you two of these in exchange for your jump drive."`
				goto weapons
			label "buy tripulse"
			action
				outfit "Tripulse Shredder" 2
			`	They order their crew to do the transfer and come to address you before leaving. "Do note that if you ever want more weapons, we will always be willing to trade them for jump drives in the job board. However, we can always offer money instead if that is of higher value to you. Of course, we can only do this exchange here on <origin>, given it is where these advanced weapons are produced and stocked."`
			label end
			branch spareJD
				"outfit (cargo): Jump Drive" + "outfit (flagship installed): Hyperdrive" + "outfit (flagship installed): Scram Drive" + "outfit (flagship installed): Jump Drive" > 1
			action
				outfit "Hyperdrive" 1
			label spareJD
			`	The engineer leaves and you return to your ship after being escorted out of the facility.`
				accept

			label dodge
			action
				"unfettered: jd to sell" += 2
				"unfettered: dodged the blade" ++
			`	<as before (run)> manage to dodge the blade but are then left defenseless when the same Unfettered closes with another one and slashes down to strike. They stop at the last possible moment, dissatisfaction clear on their face.`
			branch fail
				has "unfettered: flee from the blade"
			`	"So this is how you 'fight,' Captain? You hide? You dodge? You refuse to seize our weapons, so you will not have them."`
				goto fail
			label flee
			action
				"unfettered: jd to sell" += 4
				"unfettered: flee from the blade" ++
			`	<as before (flee)> run away from the blade without any difficulty, but the Hai that threw it catches up to you in mere seconds and immobilizes you with their blade on your throat.`
			`	"You disappoint me, Captain. In battle it is of great importance that you identify your advantages over the enemy and not show weakness by running, else they will come in for the kill. You have failed in both ways here. Never would you have been able to outrun me. All you did was show fear."`
				to display
					not "unfettered: dodged the blade"
			label fail
			action
				"unfettered: blade rodeo" ++
			`	"You really keep on disappointing me, Captain. At one time you tried to avoid a fight you could not flee from, and the other to dodge a weapon that was so readily presented to you? Maybe you truly are no warrior and let most of your subordinates do the dirty work."`
				to display
					"unfettered: flee from the blade" == 1
					"unfettered: dodged the blade" == 1
			`	"I will not keep on teaching you the same lesson! You had your chance. We cannot accept one that does not learn from their mistakes. It seems that we cannot trust you with our most advanced weapons." She then leaves, visibly irritated.`
				to display
					or
						"unfettered: dodged the blade" > 1
						"unfettered: flee from the blade" > 1
				decline
			`	<leave> The engineer, who had watched the fight then explains, "Since you have failed the test we cannot give you access to our vault yet. Our weapons are only meant for the most capable of warriors. You will of course still be able to trade jump drives for money, but until you otherwise prove yourself, that is the extent of it."`
			`	"This mistake is not permanent; I am sure she will happily forgive you, if you will only bring us more jump drives. Another engineer will be waiting for you at your hatch when that is the case."`
				to display
					"unfettered: jd to sell" < "Unfettered Jump Drive 4: failed"
				defer
			`	"In fact, your reputation for bringing us jump drives is so great she has no choice but to forgive you in the near future. Another engineer will be waiting for you at your hatch when that is the case."`
				to display
					"unfettered: jd to sell" > "Unfettered Jump Drive 4: failed"
				defer
	on accept
		clear "unfettered: uninterested in weapons"
		clear "unfettered: blade rodeo"
		clear "choice: turret"
		clear "choice: tripulse"
		clear "choice: blaster"
		outfit "Jump Drive" -1
		"reputation: Hai (Unfettered)" >?= 40
		fail
